package yuan.deng.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

public class DataSourceUtils {
    //构造方法私有
    private DataSourceUtils(){}
    //声明数据源变量
    private static DataSource dataSource;
    Connection connection =null;
    //静态代码块
    static {
        try{
            InputStream resourceAsStream = DataSourceUtils.class.getClassLoader().getResourceAsStream("druid.properties");
            Properties properties=new Properties();
            properties.load(resourceAsStream);
            dataSource = DruidDataSourceFactory.createDataSource(properties);
            Connection connection = dataSource.getConnection();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
